<template>
	<view >

	<div>
		<image src="../../static/e.png" style="width: 100%;"></image>
		<div style="width: 70px;  height: 70px; border: 4px solid white; position: fixed; top: 140rpx; left:40%; border-radius: 50%;">
						<image src="../../static/headTwo.jpg" style="width: 70px; height: 70px; border-radius: 50%;"></image>
						<div style="width: 300px; height: 15px;font-size: 16px; position: relative; top: 13px; right: 35px;">
							<text style="color: white;">{{this.headInfo}}</text>
						</div>
					</div>
	</div>
		<uni-nav-bar height="55px"  :fixed="true" shadow background-color="while" status-bar right-icon="right"
			@clickTitle="editInfo()">
			<uni-icons type="person-filled" color="brown" size="30"
				style="margin-top: 12px;margin-left: -55px;position: absolute;"></uni-icons>
			<uni-title color="black" title="编辑资料"
				style="position: absolute;margin-left: -10px;margin-top: 10px;"></uni-title>
		</uni-nav-bar>
		<uni-nav-bar height="55px" :fixed="true" shadow background-color="white" status-bar right-icon="right"
			@clickTitle="questionInfo">
			<uni-icons type="info-filled" color="blue" size="30"
				style="margin-top: 12px;margin-left: -55px;position: absolute;"></uni-icons>
			<uni-title color="black" title="常见问题"
				style="position: absolute;margin-left: -10px;margin-top: 10px;"></uni-title>
		</uni-nav-bar>
		<uni-nav-bar height="55px" :fixed="true" shadow background-color="white" status-bar right-icon="right"
			@clickTitle="aboutInfo">
			<uni-icons type="heart-filled" color="orangered" size="30"
				style="margin-top: 12px;margin-left: -55px;position: absolute;"></uni-icons>
			<uni-title color="black" title="关于我们"
				style="position: absolute;margin-left: -10px;margin-top: 10px;"></uni-title>
		</uni-nav-bar>
		<uni-nav-bar height="55px" :fixed="true" shadow background-color="white" status-bar right-icon="right"
			@clickTitle="setInfo">
			<uni-icons type="gear-filled" color="black" size="30"
				style="margin-top: 12px;margin-left: -55px;position: absolute;"></uni-icons>
			<uni-title color="black" title="应用设置"
				style="position: absolute;margin-left: -10px;margin-top: 10px;"></uni-title>
		</uni-nav-bar>
		<uni-nav-bar height="55px" :fixed="true" shadow background-color="white" :border="false" status-bar @clickTitle="share"
			right-icon="right">
			<uni-icons type="redo-filled" color="teal" size="30"
				style="margin-top: 12px;margin-left: -55px;position: absolute;"></uni-icons>
			<uni-title color="black" title="分享"
				style="position: absolute;margin-left: -10px;margin-top: 10px;"></uni-title>
		</uni-nav-bar>
		
		<button type="warn" @click="logout"  style="border-radius: 20px; width: 250px; position: relative; top: 34px; left: 0px;">退出登录</button>


		<!-- 普通弹窗 -->
		<uni-popup ref="popup" background-color="#fff" >
			<view class="popup-content" style="width: 420rpx; height: 250rpx;">
				<text class="text">已是最新版本！v1.0.1</text></view>
		</uni-popup>				

	</view>
</template>

<script>
	import {baseUrl} from 'libs/util/global'
	export default {
		data() {
			return {
				loginUserName: null,
				loginUserType: null,
				userId: null,
				headInfo:''
			}
		},
		onLoad(option) {
			uni.getStorage({
				key: 'userName',
				success:(res)=> {
					console.log(res.data + "登录用户id:"+res.data)
					this.loginUserName = res.data
				}
			});
			uni.getStorage({
				key: 'isChain',
				success:(res) =>{
					console.log(res.data + "登录用户类型:"+res.data)
					this.loginUserType = res.data
				}
			});
			uni.getStorage({
				key: 'userId',
				success:(res) =>{
					console.log(res.data + "登录用户id:"+res.data)
					this.userId  = res.data
				}
			});
		},
		mounted() {
			this.getUserInfo()	
		},
		methods: {
			// 退出登录		
			logout(){
				uni.removeStorage({
					key: 'userId',
					success: function (res) {
						console.log('success');
					}
				});
				uni.removeStorage({
					key: 'isChain',
					success: function (res) {
						console.log('success');
					}
				});

				uni.clearStorageSync();
				uni.clearStorage();
				uni.reLaunch({
					url: '/pages/login'
				})	
			},
			// 获取当前登录用户角色信息
			getUserInfo(){
				let url = baseUrl+'/role/' + this.userId +"/"+ this.loginUserType
				uni.request({
					url: url,
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					method: 'GET',
					data: {},
					success: (res) => {		
						console.log(res)
						this.headInfo =  res.data.msg + ": " + this.loginUserName
					}
				})
			},
			// 编辑资料
			editInfo(){
				console.log("编辑资料")
				uni.navigateTo({
					url:'/pages/myInfo/editInfo'
				})
			},
			//常见问题
			questionInfo(){
				uni.navigateTo({
					url:'/pages/myInfo/questionInfo'
				})
			},
			//关于我们
			aboutInfo(){
				uni.navigateTo({
					url:'/pages/myInfo/aboutInfo'
				})
			},
			// 应用设置
			setInfo(){
				uni.navigateTo({
					url:'/pages/myInfo/applicationSetInfo'
				})
			},
			// 分享
			share(){
				uni.navigateTo({
					url:'/pages/myInfo/share/share'
				})
			}
		}
	}
</script>

	 
<style>

	

	.button-text {
		color: #fff;
		font-size: 12px;
	}
	


</style>